home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / overview / dtscpluslibrary / sources / toolbox.cp < prev    next >
Encoding:
Text File  |  2000-09-28  |  2.9 KB  |  112 lines

  1. /*
  2.     File:        Toolbox.cp
  3.  
  4.     Contains:    TToolbox is a Toolbox utility class, used for initialization and Toolbox functions.
  5.                   TToolbox.cp contains the class body information for the TToolbox member functions.
  6.   
  7.     Written by: Kent Sandvik    
  8.  
  9.     Copyright:    Copyright © 1992-1999 by Apple Computer, Inc., All Rights Reserved.
  10.  
  11.                 You may incorporate this Apple sample source code into your program(s) without
  12.                 restriction. This Apple sample source code has been provided "AS IS" and the
  13.                 responsibility for its operation is yours. You are not permitted to redistribute
  14.                 this Apple sample source code as "Apple sample source code" after having made
  15.                 changes. If you're going to re-distribute the source, we require that you make
  16.                 it clear in the source that the code was descended from Apple sample source
  17.                 code, but that you've made changes.
  18.  
  19.     Change History (most recent first):
  20.                 8/18/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  21.                 
  22.  
  23. */
  24. // Include files
  25. #ifndef _TOOLBOX_
  26. #include "Toolbox.h"
  27. #endif
  28.  
  29.  
  30. // _________________________________________________________________________________________________________ //
  31. // TToolbox class member function implementations
  32. //    CONSTRUCTORS & DESTRUCTORS
  33. #pragma segment Toolbox                   
  34. TToolbox::TToolbox()
  35. // Default constructor.
  36. {
  37. }
  38.  
  39.  
  40. #pragma segment Toolbox
  41. TToolbox::~TToolbox()
  42. // Virtual destructor, we are not doing anything inside this one just now, note 
  43. // that virtual destructors should not be inlined
  44. {
  45. }
  46.  
  47.  
  48. //    INITIATION ROUTINES
  49. #pragma segment Toolbox
  50. void TToolbox::InitializeToolbox()
  51. // Initialize the Macintosh Toolbox environment, standard initialization routines.
  52. {
  53.     ::InitGraf(&qd.thePort);
  54.     ::InitFonts();
  55.     ::InitWindows();
  56.     ::InitMenus();
  57.     ::TEInit();
  58.     ::InitDialogs(NULL);
  59.     ::InitCursor();
  60. }
  61.  
  62.  
  63. // MAIN INTERFACE
  64. #pragma segment Toolbox
  65. void TToolbox::PullApplicationToFront(short nCount)
  66. // Make sure that any possible splash screens are placed front-most.
  67. {
  68.     EventRecord anEvent;
  69.     short aCount;
  70.  
  71.     for (aCount = 1; aCount <= nCount; aCount++)        // pluck out a couple of events until things are OK
  72.         ::EventAvail(everyEvent, &anEvent);
  73. }
  74.  
  75.  
  76. #pragma segment Toolbox
  77. Boolean TToolbox::CreateMasterPointers(short nMasterPtr)
  78. // Create n amount of Master Pointers.
  79. {
  80.     OSErr anErr;
  81.  
  82.     while (nMasterPtr--)
  83.         ::MoreMasters();
  84.  
  85.     anErr = MemError();
  86.     VASSERT(anErr == noErr, ("Problems with MoreMasters = %d", anErr));
  87.     
  88.     if(anErr == noErr)
  89.         return true;
  90.     else
  91.         return false;            // we had problems, and signal this
  92. }
  93.  
  94.  
  95. #pragma segment Toolbox
  96. void TToolbox::Initialize()
  97. // Default initialization of Toolbox routines.
  98. {
  99.     this->InitializeToolbox();
  100.     this->CreateMasterPointers();
  101.     this->PullApplicationToFront();
  102. }
  103.  
  104.  
  105. // _________________________________________________________________________________________________________ //
  106.  
  107. /*    Change History (most recent last):
  108.   No        Init.    Date        Comment
  109.   1            khs        6/6/92        New file
  110.   2            khs        1/3/93        Cleanup
  111. */
  112.